<template>
    <div>
        <h3>小黑记事本</h3>
        <input 
        @keyup.enter="handleAdd"
        placeholder="请输入任务" v-model="todoName"><button @click="handleAdd">添加任务</button>
    </div>
</template>
<script>
export default{
    data(){
        return {
            todoName:''
        }
    },
    methods:{
        handleAdd(){
           if(this.todoName.trim()===''){
            alert('重新')
           }
            this.$emit('add',this.todoName)
            this.todoName=''
        }
    }
}
</script>
<style>
</style>